package com.dcc.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.dcc.bean.ContainerInfoResponse;

import io.swagger.annotations.Api;

//@ApiIgnore // 忽视该类显示在API文档中
@RestController
@RequestMapping("/test")
@Api(value = "Controller", tags = "测试1")
public class TestController {
    @GetMapping("/test")
    public String test(){
        return "试一下子！";
    }
    
    @GetMapping("/info")
    public ContainerInfoResponse getInfo() {
        String name = System.getenv().getOrDefault("HOSTNAME", "LOCAL_DEV");
        String ip = System.getenv().getOrDefault("HOST_IP", "127.0.0.1");
        return new ContainerInfoResponse(
            null, // Docker ID前12位
            name, 
            ip
        );
    }
    
    @GetMapping("/excepion")
    public ContainerInfoResponse excepion() {
        String name = System.getenv().getOrDefault("HOSTNAME", "LOCAL_DEV");
        String ip = System.getenv().getOrDefault("HOST_IP", "127.0.0.1");
        System.out.println(1/0);
        return new ContainerInfoResponse(
            null, // Docker ID前12位
            name, 
            ip
        );
    }
}
